package code3;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Code {

    public static void main(String[] args) {

        Map<String, Integer> map = new HashMap<>();
        String str = "123,456,789,123,456";
        String[] arr = str.split(",");

        Set<String> set = new HashSet<>();
        for(int i=0; i<arr.length; i++){
            set.add(arr[i]);
        }

        int n = 0;
        for(String s : set){
            for(int i=0; i<arr.length; i++){
                if(s.equals(arr[i])){
                    n++;
                }
            }
            map.put(s, n);
            System.out.println(s+"出现了"+n+"次");
            n = 0;
        }
    }
}
